#include <iostream>
#include <vector>
#include "util.h"
using namespace std;

class Solution {
public:
    bool isValidBST(TreeNode *root) {
        if (root == NULL) return true;
        vector<int> v;
        isValidBST(root, v);
        for(vector<int>::iterator it = v.begin(); it!=v.end()-1; it++){
            if(*it > *(it+1) ) return false;
        }
        return true;
    }
    void isValidBST(TreeNode *root, vector<int>& v) {
        if (root == NULL) return;
        isValidBST(root->left, v);
        v.push_back(root->val);
        isValidBST(root->right, v);
    }
}
